import sys
import asyncio
import logging
from core.client import ClientApp

# 配置日志
logging.basicConfig(
    level=logging.INFO,
    format='%(asctime)s - %(levelname)s - %(message)s'
)
logger = logging.getLogger(__name__)

def main():
    try:
        if len(sys.argv) != 2:
            logger.error("缺少token参数")
            sys.exit(1)
        token = sys.argv[1]
        app = ClientApp(token)
        asyncio.run(app.run())
    except KeyboardInterrupt:
        logger.info("应用被用户中断")
    except SystemExit:
        logger.info("程序已退出")
    except Exception as e:
        logger.error(f"应用运行错误: {e}")

if __name__ == "__main__":
    main()
